import { ref } from 'vue'
import dayjs from 'dayjs'

export default function () {
    const welcomeTime = ref('')
    const weekStr = ref('')
    const today = dayjs().format('YYYY年MM月DD日')
    const todayStr = ref(today)

    let hour = new Date().getHours()
    let week = new Date().getDay()
    if (hour > 4 && hour <= 12) {
        welcomeTime.value = '早上好！'
    } else if (hour > 12 && hour <= 18) {
        welcomeTime.value = '下午好！'
    } else if (hour > 18 || hour < 4) {
        welcomeTime.value = '晚上好！'
    }
    switch (week) {
        case 1:
            weekStr.value = '周一'
            break
        case 2:
            weekStr.value = '周二'
            break
        case 3:
            weekStr.value = '周三'
            break
        case 4:
            weekStr.value = '周四'
            break
        case 5:
            weekStr.value = '周五'
            break
        case 6:
            weekStr.value = '周六'
            break
        case 0:
            weekStr.value = '周日'
            break
    }

    return { welcomeTime, weekStr, todayStr }
}
